<div id="content">
    <div class="grid_container">
        <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon list">
                    </span>
                    <h6>
                        TRIAGE
                    </h6>
                </div>
                <div class="widget_content">
                    <div class=" page_content">
                        <div class="invoice_container">
                            <div class="invoice_action_bar">
                                <div class="btn_30_light">
                                    <a href="#" title="Pay Now"><span class="icon zone_money_co"></span></a>
                                </div>
                                <div class="btn_30_light">
                                    <a href="#" title="Print"><span class="icon printer_co"></span></a>
                                </div>
                                <div class="btn_30_light">
                                    <a href="#" title="Download .pdf"><span class="icon drive_disk_co"></span></a>
                                </div>
                            </div>
                            <div class="grid_6 invoice_num">
                                <span>
                                    <?php echo $ficha['Paciente']['nombres'] . ' ' . $ficha['Paciente']['ap_paterno'] . ' ' . $ficha['Paciente']['ap_materno'] ?>
                                </span>
                            </div>

                            <div class="grid_4 invoice_date">
                                EDAD: <?php echo $edad; ?> a&ntilde;os
                            </div>
                            <span class="clear">
                                &nbsp;
                            </span>
                            <div class="grid_4 invoice_date">
                                FECHA CONSULTA:
                                <?php echo $ficha['Consultasexterna']['fecha']; ?>
                            </div>
                            <div class="grid_4 invoice_date">

                                HORA:
                                <?php echo $ficha['Consultasexterna']['hora'] ?>
                            </div>
                            <span class="clear">
                                &nbsp;
                            </span>
                            <div class="grid_3 invoice_title">
                                <h5>
                                    Motivo consulta:
                                </h5>
                            </div>
                            <div class="grid_6 invoice_num">
                                <span>
                                    <?php echo $ficha['Trauma']['nombre'] ?>
                                </span>
                            </div>
                            <span class="clear">
                            </span>

                            <?php echo $this->Form->create('Paciente', array('id' => "form103", 'action' => 'signosvitales', 'class' => "form_container left_label valid_tip"))
                            ?>
                            <div class="grid_6">
                                <!-- <form action="#" method="post" id="form103" class="form_container left_label valid_tip">-->

                                <div class="widget_wrap">
                                    <div class="widget_top">
                                        <span class="h_icon list">
                                        </span>
                                        <h6>
                                            REGISTRO SIGNOS VITALES DEL PACIENTE
                                        </h6>
                                    </div>
                                    <div class="widget_content">
                                        <ul>
                                            <?php echo $this->Form->hidden('Consultasexterna.triage', array('value' => $ficha['Trauma']['trauma'])); ?>
                                            <?php echo $this->Form->hidden('Consultasexterna.id', array('value' => $ficha['Consultasexterna']['id'])); ?>
                                            <?php echo $this->Form->hidden('Consultasexterna.edad', array('value' => $edad)); ?>
                                            <?php
                                            $i = 0;
                                            foreach ($signos as $s):?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.fecha", array('value' => date('Y-m-d'))) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.hora", array('value' => date('H:i:s'))) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.paciente_id", array('value' => $ficha['Paciente']['id'])) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.edad", array('value' => $edad)) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.consultasexterna_id", array('value' => $ficha['Consultasexterna']['id'])) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.medida_id", array('value' => $s['Medida']['id'])) ?>
                                                <?php echo $this->Form->hidden("MedidasPaciente.$i.user_id", array('value' => $this->Session->read('Auth.User.id'))) ?>
                                                <li>
                                                    <?php if($s['Medida']['id'] ==8):?>
                                                    <div class="form_grid_12">
                                                            <label class="field_title">
                                                                <?php echo $s['Medida']['codigo']?>
                                                                <span class="required">(<?php echo $s['Medida']['nombre']?>)</span>
                                                            </label>
                                                            <div class="form_input">
                                                                <div class=" form_grid_2 alpha">
                                                                    <?php echo $this->Form->text("MedidasPaciente.$i.altura", array('id' => 'alt', 'tabindex' => 1, 'class' => 'validate number')) ?>
                                                                    <span class=" label_intro">Anote la altura aqu&iacute;</span>
                                                                </div>
                                                                <div class=" form_grid_2">
                                                                    <?php echo $this->Form->text("MedidasPaciente.$i.peso", array('id' => 'peso', 'tabindex' => 1, 'class' => 'validate number')) ?>
                                                                    <span class=" label_intro">Anote el peso aqu&iacute;</span>
                                                                </div>
                                                                <div class=" form_grid_2">
                                                                    <?php echo $this->Form->hidden("MedidasPaciente.$i.dato", array('id' => 'midato')) ?>
                                                                    <?php echo $this->Form->text("MedidasPaciente.$i.datito", array('id' => 'valor', 'disabled' => 'disabled')) ?>
                                                                    <span class=" label_intro">IMC</span>
                                                                </div>
                                                                <span class="clear"></span>
                                                            </div>
                                                        </div>
                                                        <script>
                                                            function redondeo2decimales(numero)
                                                            {
                                                                var original = parseFloat(numero);
                                                                var result = Math.round(original * 100) / 100;
                                                                return result;
                                                            }
                                                            $("#peso").change(function() {
                                                                var altura = Number($("#alt").val());

                                                                var peso = Number($("#peso").val());

                                                                var resultado = Number(peso / (altura * altura));

                                                                var total = redondeo2decimales(resultado * 10000);
                                                                $("#midato").val(total);
                                                                $("#valor").val(total);
                                                                
                                                            });
                                                        </script>
                                                    <?php else:?>
                                                    
                                                    <div class="form_grid_12">
                                                        
                                                        <label class="field_title">
                                                            <?php echo $s['Medida']['codigo'] ?>
                                                            <span class="required">
                                                                (
                                                                <?php echo $s['Medida']['nombre'] ?>
                                                                )
                                                            </span>
                                                        </label>
                                                        <div class="form_input">
                                                            <div class="form_grid_4">
                                                                <?php
                                                                echo $this->Form->text("MedidasPaciente.$i.dato", array('tabindex' => 1, 'class' => 'validate number'))
                                                                ?>
                                                                <span class=" label_intro">
                                                                    Anote el resultado aqu&iacute;
                                                                </span>
                                                            </div>
                                                            <span class="clear">
                                                            </span>
                                                        </div>
                                                    </div>
                                                    <?php endif;?>
                                                </li>

                                                <?php
                                                $i++;
                                            endforeach;
                                            ?>
                                                
                                        </ul>
                                    </div>
                                </div>

                            </div>
                            <?php if(!empty($sintomas)):?>
                            <div class="grid_6">
                                <div class="widget_wrap">
                                    <div class="widget_top">
                                        <span class="h_icon list">
                                        </span>
                                        <h6>
                                            REGISTRO SIGNOS y S&Iacute;NTOMAS DEL PACIENTE
                                        </h6>
                                    </div>
                                    <div class="widget_content">
                                        <ul>
                                            <?php
                                            $i = 0;
                                            foreach ($sintomas as $s):
                                                ?>
                                                <?php echo $this->Form->hidden("ConceptosPaciente.$i.paciente_id", array('value' => $ficha['Consultasexterna']['paciente_id'])) ?>
                                                <?php echo $this->Form->hidden("ConceptosPaciente.$i.consultasexterna_id", array('value' => $ficha['Consultasexterna']['id'])) ?>
                                                <?php echo $this->Form->hidden("ConceptosPaciente.$i.alerta_id", array('value' => $s['Alerta']['color'])) ?>
                                                <?php echo $this->Form->hidden("ConceptosPaciente.$i.estado", array('value' => 1)) ?>
                                                <?php echo $this->Form->hidden("ConceptosPaciente.$i.user_id", array('value' =>$this->Session->read('Auth.User.id'))) ?>
                                                <li style="background: <?php echo $s['Alerta']['estilo'] ?>">
                                                    <div class="form_grid_12">
                                                        <input name="data[ConceptosPaciente][<?php echo $i ?>][concepto_id]" class="checkbox" type="checkbox" value="<?php echo $s['Concepto']['id'] ?>" tabindex="2">
                                                        <span><?php echo $s['Concepto']['signo'] ?></span>
                                                    </div>
                                                </li>
                                                <div class="clear"></div>
                                                <?php
                                                $i++;
                                            endforeach;
                                            ?>

                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <?php endif;?>
                            <div class="grid_12">
                                <ul>
                                    <li>
                                        <div class="form_grid_12">
                                            <div class="form_input">
                                            <div id="enviaDatos">
                                                <button type="submit" class="btn_small btn_blue">
                                                    <span>
                                                        Guardar signos vitales
                                                    </span>
                                                </button>
                                                <button type="reset" class="btn_small btn_orange">
                                                    <span>
                                                        Limpiar datos
                                                    </span>
                                                </button>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                            <span class="clear">
                            </span>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <span class="clear">
    </span>
</div>

<script>
    $(document).ready(function() {
        $('#enviaDatos').click(function() {
            $('#enviaDatos').hide('slow');
        });
    });
</script>

